﻿Ext.define('SmartClient.Application',
   {
      extend: 'Deft.mvc.Application',

      requires: ['SmartClient.utils.CookieUtils', 'SmartClient.utils.CommonFunctions'],

      init: function ()
      {
         // Configure the DeftJS IoC container
         Deft.Injector.configure(
            {
               loginStore: 'SmartClient.store.MockLoginStore',
               productsStore: 'SmartClient.store.MockProductsStore',
               ordersStore: 'SmartClient.store.MockOrdersStore'
            });

         Ext.tip.QuickTipManager.init();

         var userCookieValue = SmartClient.utils.CookieUtils.getCookieValue(this.self.USER_TYPE_COOKIE);
         if (!userCookieValue)
         {
            Ext.create('SmartClient.view.LoginView').center();
         }
         else if (userCookieValue === SmartClient.Application.CUSTOMER_USER)
         {
            Ext.create('SmartClient.view.Viewport');
         }
         else if (userCookieValue === SmartClient.Application.TECHNOLOGIST_USER)
         {
            Ext.create('SmartClient.view.SearchOrdersView');
         }
      },

      statics:
         {
            USER_COOKIE: 'User',
            USER_TYPE_COOKIE: 'UserType',
            EDITED_ORDER_COOKIE: 'EditedOrder',
            ADDED_PRODUCTS_COOKIE: 'AddedProducts',
            CUSTOMER_USER: 'Customer',
            TECHNOLOGIST_USER: 'Technologist',
            ADDED_PRODUCTS_DELIMITER: '|',
            PCS_UNITS: 'pcs',
         },
   });